$(function () {
    Time();
    load();
})

function Time() {
    var time = new Date();
    var y = time.getFullYear();
    var mon = time.getMonth() + 1; //0-11
    var d = time.getDate();
    var h = time.getHours();
    var m = time.getMinutes();
    var s = time.getSeconds();
    $("#datetime").val(y + "-" + mon + "-" + d + " " + h + ":" + m + ":" + s);
}

function load() {
    let u = localStorage.getItem("user");
    let user = JSON.parse(u);
    $("#name").val(user.rname);
    let DfileSHID = JSON.parse(localStorage.getItem("DfileSHID"));
    $("#productname").val(DfileSHID.productname);
    $("#productid").val(DfileSHID.productid);
    $("#sjr").val(DfileSHID.designer);

    $.post("/Dmoduledetails.do/listxb", {ParentId:DfileSHID.designid}, function (sdata) {
        console.log(sdata)
        let str = " <tr >\n" +
            "           <th>物料名称</th>\n" +
            "           <th>物料编号</th>\n" +
            "           <th>用途类型</th>\n" +
            "           <th>数量</th>\n" +
            "           <th>单位</th>\n" +
            "           <th>单价(元)</th>\n" +
            "           <th>小计(元)</th>\n" +
            "       </tr>\n";
        $.each(sdata, function (index, item) {
            str +=
                "  <tr>\n" +
                "      <td>" + item.productname + "</td>\n" +
                "      <td>" + item.productid + "</td>\n" +
                "      <td>" + (item.type == 'Y001-1' ? '商品' : item.type == 'Y001-2' ? '物料' : '') + "</td>\n" +
                "      <td>"+item.amount+"</td>\n" +
                "      <td><span class='amountunit' >" + item.amountunit + "</span></td>\n" +
                "      <td><span class='realcostprice' >" + item.costprice + "</span></td>\n" +
                "      <td><span class='xiaoji'>"+item.subtotal+"</span></td>\n" +
                "  </tr>";
        })
        $("#tableAdd").html(str);
    })



}
function hui() {
    location.href = "../../tan_kai/Dmwtg.html";
    $(".ad").removeAttr("hidden");
    $("#XQ").removeAttr("hidden");
    Time();
    load();
}
function update1() {
    let DfileSHID = JSON.parse(localStorage.getItem("DfileSHID"));
    $.post("/Dmodule.do/upfliewtg", {id:  DfileSHID.id,checktag:$("input[name=checktag]:checked").val()}, function (asd) {
        $("#staticBackdrop").modal("show");
        localStorage.removeItem("DfileSHID")
    })
}
function hh() {
    location.href="../../tan_kai/Dmwtg.html";
}
